# -*- coding: utf-8 -*-
"""
Created on Wed Sep 18 21:52:38 2024

@author: Administrator
"""

from tkinter import *


def draw_house_at(x,y,w,h,roof_color,wall_color,canvas):
    rtop_x=x+w/2 #house top x
    wtop_y=y+h/2 #house top y
    bottom_x=x+w #house bottom x
    bottom_y=y+h #house bottom y
    canvas.create_polygon(rtop_x,y, #顶点
                          x,wtop_y, #左下
                          x+w,wtop_y, #右上
                          outline=roof_color,
                          fill = roof_color
                          )
    canvas.create_rectangle(x,wtop_y,
                            bottom_x,bottom_y,
                            outline=wall_color,
                            fill=wall_color
                            
                            )
    
tk = Tk()

canvas = Canvas(tk,width=800,height=400,bd=0)
canvas.pack()


x0 = 0
w = 100
h = 150
PAD = 150

for x in range(4) :
    draw_house_at(x0, 50, w, h, "red", "blue", canvas)
    x0 = x0 + PAD


tk.mainloop()

  
    
    